#pragma once

#ifndef __VERSION_HELPER_H__
#define __VERSION_HELPER_H__

#include "Common.h"
#include "LogManager.h"

typedef struct
{
	string CurrentExePath;
	string CompanyName;
	string FileDescription;
	string FileVersion;
	string InternalName;
	string LegalCopyright;
	string OriginalFilename;
	string ProductName;
	string ProductVersion;
} VersionInformations;

// Helper for version informations.
class VersionHelper
{
public:
	// Retrieves the version informations.
	static bool GetVersionInformations(VersionInformations& versionInformations);

private:
	// Try to retrieves the version informations parameters.
	static bool TryGetParameters(wchar_t* fileName, const DWORD& fileNameSize, DWORD& fileVersionInfoSize, HANDLE& hMem, VersionInformations& versionInformations);

	// Try to retrieves the version informations buffer.
	static bool TryGetBuffer(const wchar_t* fileName, const DWORD& fileVersionInfoSize, const HANDLE& hMem, LPVOID& versionInformations);

	// Try to retrieves the version informations resources prefix.
	static bool TryGetPrefix(LPVOID& versionInformations, wchar_t* result);

	// Try to retrieves the specified version informations resource.
	static bool TryGetResource(LPVOID& buffer, const wchar_t* prefix, const wchar_t* resourceName, string& result);
};

#endif  // __VERSION_HELPER_H__